/* -----------------------------------------------------------------------
 * Name:   Krishan Kodali
 * Course: CS 362
 * Date:   01/26/14
 * unittest1.c is to test getCost() funtion in dominion.c 
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>

char* getCard(int cardNumber);
int checkCard(int testCard, int testReturn);


int checkCard(int testingCard, int testingCardCost){
    if (testingCard == curse){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 0");
        printf("\n\n");
    	assert (testingCardCost == 0);
    }
    else if (testingCard == estate){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 2");
        printf("\n\n");
    	assert (testingCardCost == 2);
    }
    else if (testingCard == duchy){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 5");
        printf("\n\n");
    	assert (testingCardCost == 5);
    }
    else if (testingCard == province){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 8");
        printf("\n\n");
    	assert (testingCardCost == 8);
    }
    else if (testingCard == copper){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 0");
        printf("\n\n");
    	assert (testingCardCost == 0);
    }
    else if (testingCard == silver){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 3");
        printf("\n\n");
    	assert (testingCardCost == 3);
    }
    else if (testingCard == gold){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 6");
        printf("\n\n");
    	assert (testingCardCost == 6);
    }
    else if (testingCard == adventurer){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 6");
        printf("\n\n");
    	assert (testingCardCost == 6);
    }
    else if (testingCard == council_room){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 5");
        printf("\n\n");
    	assert (testingCardCost == 5);
    }
    else if (testingCard == feast){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 4");
        printf("\n\n");
    	assert (testingCardCost == 4);
    }
    else if (testingCard == gardens){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 4");
        printf("\n\n");
    	assert (testingCardCost == 4);
    }
    else if (testingCard == mine){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 5");
        printf("\n\n");
    	assert (testingCardCost == 5);
    }
    else if (testingCard == remodel){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 4");
        printf("\n\n");
    	assert (testingCardCost == 4);
    }
    else if (testingCard == smithy){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 4");
        printf("\n\n");
    	assert (testingCardCost == 4);
    }
    else if (testingCard == village){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 3");
        printf("\n\n");
    	assert (testingCardCost == 3);
    }
    else if (testingCard == baron){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 4");
        printf("\n\n");
    	assert (testingCardCost == 4);
    }
    else if (testingCard == great_hall){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 3");
        printf("\n\n");
    	assert (testingCardCost == 3);
    }
    else if (testingCard == minion){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 5");
        printf("\n\n");
    	assert (testingCardCost == 5);
    }
    else if (testingCard == steward){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 3");
        printf("\n\n");
    	assert (testingCardCost == 3);
    }
    else if (testingCard == tribute){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 5");
        printf("\n\n");
    	assert (testingCardCost == 5);
    }
    else if (testingCard == ambassador){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 3");
        printf("\n\n");
    	assert (testingCardCost == 3);
    }
    else if (testingCard == cutpurse){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 4");
        printf("\n\n");
    	assert (testingCardCost == 4);
    }
    else if (testingCard == embargo){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 2");
        printf("\n\n");
    	assert (testingCardCost == 2);
    }
    else if (testingCard == outpost){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 5");
        printf("\n\n");
    	assert (testingCardCost == 5);
    }
    else if (testingCard == salvager){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 4");
        printf("\n\n");
    	assert (testingCardCost == 4);
    }
    else if (testingCard == sea_hag){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 4");
        printf("\n\n");
    	assert (testingCardCost == 4);
    }
    else if (testingCard == treasure_map){
    	printf("The getCost(%s) card cost is: %d  ", getCard(testingCard), testingCardCost);
    	printf("Expected: 4");
        printf("\n\n");
    	assert (testingCardCost == 4);
    }
    else {
    	printf("%d  ", testingCardCost);
    	printf("Expected: -1");
        printf("\n\n");
    	assert (testingCardCost == -1);
    }
    return 0;
}

char* getCard(int cardNumber){
    if (cardNumber == curse){
        return "curse";
    }
    if (cardNumber == estate){
        return "estate";
    }
    if (cardNumber == duchy){
        return "duchy";
    }
    if (cardNumber == province){
        return "province";
    }
    if (cardNumber == copper){
        return "copper";
    }
    if (cardNumber == silver){
        return "silver";
    }
    if (cardNumber == gold){
        return "gold";
    }
    if (cardNumber == adventurer){
        return "adventurer";
    }
    if (cardNumber == council_room){
        return "council_room";
    }
    if (cardNumber == feast){
        return "feast";
    }
    if (cardNumber == gardens){
        return "gardens";
    }
    if (cardNumber == mine){
        return "mine";
    }
    if (cardNumber == remodel){
        return "remodel";
    }
    if (cardNumber == smithy){
        return "smithy";
    }
    if (cardNumber == village){
        return "village";
    }
    if (cardNumber == baron){
        return "baron";
    }
    if (cardNumber == great_hall){
        return "great_hall";
    }
    if (cardNumber == minion){
        return "minion";
    }
    if (cardNumber == steward){
        return "steward";
    }
    if (cardNumber == tribute){
        return "tribute";
    }
    if (cardNumber == ambassador){
        return "ambassador";
    }
    if (cardNumber == cutpurse){
        return "cutpurse";
    }
    if (cardNumber == embargo){
        return "embargo";
    }
    if (cardNumber == outpost){
        return "outpost";
    }
    if (cardNumber == salvager){
        return "salvager";
    }
    if (cardNumber == sea_hag){
        return "sea_hag";
    }
    if (cardNumber == treasure_map){
        return "treasure_map";
    }
    return "fail";
}

int main() {
    int i; 
    printf ("TESTING getCost \n");
    printf ("===============\n");
    
    for (i= curse; i<= treasure_map; i++){

    printf("Testing card cost of %s:\n", getCard(i));

        checkCard(i, getCost(i));
    }

    return 0;
}
